﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Input;

namespace WPFEdit.ViewModels
{
    public class NoArgDelegateCommand : ICommand
    {
        public delegate void CommandHandler();

        private CommandHandler m_handler;

        public NoArgDelegateCommand(CommandHandler handler)
        {
            m_handler = handler;
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            m_handler();
        }
    }

    public class DelegateCommand : ICommand
    {
        public delegate void CommandHandler(object param);

        private CommandHandler m_handler;

        public DelegateCommand(CommandHandler handler)
        {
            m_handler = handler;
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            m_handler(parameter);
        }
    }
}
